import Vue from 'vue';
import Vuex from 'vuex';
import getters from './getters.js';
import user from './modules/user';
const persistPlugin = store => {
	// 读取状态
	let state = uni.getStorageSync('productMini-state');
	if (state) {
		store.replaceState(state);
	}

	// 监听状态变化
	store.subscribe((mutation, state) => {
		uni.setStoregeSync('state', state)
	})
}
Vue.use(Vuex);

const store = new Vuex.Store({
	plugins: [persistPlugin],
	modules: {
		user
	},
	getters
})
export default store;